import request from '@/config/axios'
import { defHttp } from '@/utils/http/axios';
import { RequestEnum } from '@/enums/httpEnum';
import { ServicePrefixEnum } from '@/enums/commonEnum';
import type { AxiosRequestConfig } from 'axios';

const MODULAR = '/system/sms-template';

export const Api = {
  GetSmsTemplatePage: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/page`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  GetSmsTemplate: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/get`,
    method: RequestEnum.GET,
  } as AxiosRequestConfig,
  CreateSmsTemplate: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/create`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
  UpdateSmsTemplate: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/update`,
    method: RequestEnum.PUT,
  } as AxiosRequestConfig,
  DeleteSmsTemplate: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/delete`,
    method: RequestEnum.DELETE,
  } as AxiosRequestConfig,
  SendSms: {
    url: `${ServicePrefixEnum.BASE}/${MODULAR}/send-sms`,
    method: RequestEnum.POST,
  } as AxiosRequestConfig,
}


// 查询短信模板列表
export const getSmsTemplatePage = (params) => {
  return defHttp.request({ ...Api.GetSmsTemplatePage,params})
}

// 查询短信模板详情
export const getSmsTemplate = (id: number) => {
  return defHttp.request({ ...Api.GetSmsTemplate,params:{id}})
}

// 新增短信模板
export const createSmsTemplate = (data: SmsTemplateVO) => {
  return defHttp.request({ ...Api.CreateSmsTemplate,params:data})
}

// 修改短信模板
export const updateSmsTemplate = (data: SmsTemplateVO) => {
  return defHttp.request({ ...Api.UpdateSmsTemplate,params:data})
}

// 删除短信模板
export const deleteSmsTemplate = (id: number) => {
  return defHttp.request({ ...Api.DeleteSmsTemplate,params:{id}})
}

// 发送短信
export const sendSms = (data: SendSmsReqVO) => {
  return defHttp.request({ ...Api.SendSms,params:data})
}

export interface SmsTemplateVO {
  id?: number
  type?: number
  status: number
  code: string
  name: string
  content: string
  remark: string
  apiTemplateId: string
  channelId?: number
  channelCode?: string
  params?: string[]
  createTime?: Date
}

export interface SendSmsReqVO {
  mobile: string
  templateCode: string
  templateParams: Map<String, Object>
}

// // 查询短信模板列表
// export const getSmsTemplatePage = (params: PageParam) => {
//   return request.get({ url: '/system/sms-template/page', params })
// }
//
// // 查询短信模板详情
// export const getSmsTemplate = (id: number) => {
//   return request.get({ url: '/system/sms-template/get?id=' + id })
// }
//
// // 新增短信模板
// export const createSmsTemplate = (data: SmsTemplateVO) => {
//   return request.post({ url: '/system/sms-template/create', data })
// }
//
// // 修改短信模板
// export const updateSmsTemplate = (data: SmsTemplateVO) => {
//   return request.put({ url: '/system/sms-template/update', data })
// }
//
// // 删除短信模板
// export const deleteSmsTemplate = (id: number) => {
//   return request.delete({ url: '/system/sms-template/delete?id=' + id })
// }

// 导出短信模板 todo
export const exportSmsTemplate = (params) => {
  return request.download({
    url: '/system/sms-template/export-excel',
    params
  })
}

// // 发送短信
// export const sendSms = (data: SendSmsReqVO) => {
//   return request.post({ url: '/system/sms-template/send-sms', data })
// }
